package com.lpb.spring.lpbspring.ioc;

import java.util.Map;
import java.util.Set;

/**
 * @ClassName PreBuildBeanFactory
 * @Description 对单例bean的提前初始化
 * @date 2022/11/29 23:44
 * @Version 1.0
 * @authoe linpengbo
 */
public class PreBuildBeanFactory extends DefaultBeanFactory{


    public void preInstantiateSingletons()throws Exception{

        synchronized (super.beanDefinitionMap){
            for (Map.Entry<String, BeanDefinition> entry:super.beanDefinitionMap.entrySet()) {
                String beanName = entry.getKey();
                BeanDefinition definition = entry.getValue();
                if(definition.isSingleton()){
                    super.getBean(beanName);
                }
            }
        }

    }


}
